﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using GMS.BIZ;

namespace Web
{
    /// <summary>
    /// Summary description for AutoComplete
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    [System.Web.Script.Services.ScriptService]
    public class AutoComplete : System.Web.Services.WebService
    {
        public AutoComplete()
        {
        }


        [WebMethod]
        public string[] GetTeacherNameStrings(string prefixText, int count)
        {
            List<string> items = new List<string>(count);
            DataSet myDS = Staff.GetAllStaff();
            if (myDS != null)
                {
                    for (int j = 0; j < myDS.Tables[0].Rows.Count; j++)
                    {
                        if (myDS.Tables[0].Rows[j]["tch_name"].ToString().Contains(prefixText)) items.Add(myDS.Tables[0].Rows[j]["tch_name"].ToString());                        
                    }
                }
            return items.ToArray();
        }
        
    }
}
